package com.wisdudu.blank.ui.setting.system;

import android.databinding.ObservableField;
import android.os.Bundle;

import com.kelin.mvvmlight.base.ViewModel;
import com.kelin.mvvmlight.command.ReplyCommand;
import com.wisdudu.blank.support.util.AppUtil;

/**
 * Created by ypp on 2016/8/17.
 */
public class AboutUsFragmentVM implements ViewModel {
    private static final String TAG = "AboutUsFragmentVM";
    private AboutUsFragment fragment;
    public ObservableField<String> visionName = new ObservableField<>();

    public AboutUsFragmentVM(AboutUsFragment fragment) {
        this.fragment = fragment;
        visionName.set("当前版本号" + AppUtil.getPackageInfo(fragment.mActivity).versionName);
    }

    //  功能介绍
    public ReplyCommand onIntroClick = new ReplyCommand(() -> {
        String url = "http://www.wisdudu.com/clause/action.html";
        entryWebViewActivity(url, "功能介绍");
    });

    //  系统通知
    public ReplyCommand onNoticeClick = new ReplyCommand(() -> {
        String url = "http://www.wisdudu.com/clause/notice.html";
        entryWebViewActivity(url, "系统通知");

    });
    // 使用条款
    public ReplyCommand onProvisionClick = new ReplyCommand(() -> {
        String url = "http://www.wisdudu.com/clause/clause.html";
        entryWebViewActivity(url, "使用条款");
    });
    //用户协议
    public ReplyCommand onProtocolClick = new ReplyCommand(() -> {
        String url = "http://www.wisdudu.com/clause/clause.html";
        entryWebViewActivity(url, "用户协议");
    });

    private void entryWebViewActivity(String url, String title) {
        Bundle bundle = new Bundle();
        bundle.putString(WebViewFragment.EXTRA_TITLE, title);
        bundle.putString(WebViewFragment.EXTRA_URL, url);
        WebViewFragment webViewFragment = new WebViewFragment();
        webViewFragment.setArguments(bundle);
        fragment.addFragment(webViewFragment);
    }
}
